// PsCommon.hlsl


uniform float	g_fMiscFloat;
uniform float4	g_fMiscVector;

uniform float4	g_vConstantColor;
uniform float4	g_vWaterBumpFresnel;
uniform float4	g_vWaterDepthBlend;
/*
uniform float4x4	g_fInvMVPMatrix4x4;	
uniform float4		g_vFogLayMinMax;		
uniform float4		g_vFogCameraPos;		
uniform float4		g_vFogColorWithDensity;
uniform float		g_vFogPlaneDistance;
*/	


/*
uniform float4 g_vSnowShadowColor;
uniform float4 g_vSnowLightColor;
uniform float4 g_vPerpColor;
uniform float4 g_vParallelColor;

uniform float4 g_vViewDirection;
uniform float4 g_vConstantColor;
uniform float4 g_vAmbientColor ;
uniform float4 g_vDiffuseColor;

uniform float g_fContrast;
uniform float g_fBrightness;
uniform float g_fSaturate;
uniform float g_fEdgeSize;
uniform float4 g_vContrastThresh;
#define g_fDiffuseMapIntensity g_vDiffuseColor.a
uniform float g_fDistanceInShadowScale;

uniform float4 g_vSpecularColor;
uniform float4 g_vForcedColor;
uniform float4 g_vBlendColor;
uniform float4 g_vShadowColor;

#if (LIGHT_COUNT > 0)
uniform float4 g_avLightColor[LIGHT_COUNT];
uniform float4 g_avLightSpecularColor[LIGHT_COUNT];
#endif

uniform float4 g_vLightingConstants;
#define g_fSpecularShininess g_vLightingConstants.x
#define g_fNormalBias        g_vLightingConstants.y
#define g_fParallaxScale	 g_vLightingConstants.z
#define g_fParallaxBias      g_vLightingConstants.w

uniform float	g_fAlphaTestThreshold;

uniform float4   g_vMiscParam1;
uniform float4   g_vMiscParam2;
uniform float4   g_vMiscParam3;
uniform float4   g_vMiscParam4;
uniform float4   g_vMiscParam5;

// useful functions
float4 SampleNormalMap( sampler2D _sampler, float2 _texCoord )
{
	float4 tmp = tex2D( _sampler, _texCoord );
    float3 vNormal = ( tmp.xyz - 0.5f ) * 2.0f;

    vNormal.z = sqrt( 1.0f - dot( vNormal.xy, vNormal.xy ) );

    return float4 (vNormal.x, vNormal.y, vNormal.z, tmp.w);
}

float SampleSpecularMap( sampler2D _sampler, float2 _texCoord )
{
	return tex2D(_sampler, _texCoord).a;
}

// pack a float32 into an interger32
// ref: http://www.gamedev.net/community/forums/topic.asp?topic_id=442138
float4 EncodeFloat(float v)
{
	const float4 bitSh	= float4(256*256*256,	256*256,		256,				1);
	const float4 bitMsk = float4(0,						1.0/256.0,	1.0/256.0,	1.0/256.0);

	float4 comp;
	comp = v * bitSh;
	comp = frac(comp);
	comp -= comp.xxyz * bitMsk;
	return comp;
}

// unpack an integer32 to get a float32
float DecodeFloat(float4 v)
{
	const float4 bitShifts = float4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1);
	return dot(v, bitShifts);
}
*/